package com.itheima.youdianda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.youdianda.dto.AdvimgDto;
import com.itheima.youdianda.entity.YddLink;
import com.itheima.youdianda.mapper.YddLinkMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.youdianda.service.YddLinkService;
import com.itheima.youdianda.util.MyPages;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2022-05-24
 */
@Service
public class YddLinkServiceImpl extends ServiceImpl<YddLinkMapper, YddLink> implements YddLinkService {

	@Override
	public MyPages<YddLink> listByPage(String type, String page, String limit) {
		Page<YddLink> page1 = new Page<>(Long.parseLong(page), Long.parseLong(limit));
		LambdaQueryWrapper<YddLink> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(YddLink::getType, type);
		this.page(page1, wrapper);
		MyPages<YddLink> myPage = new MyPages<>();
		myPage.setCount(page1.getTotal());
		myPage.setTotalPages(page1.getPages());
		myPage.setPageSize(page1.getSize());
		myPage.setCurrentPage(page1.getCurrent());
		myPage.setData(page1.getRecords());
		return myPage;
	}
}
